{{Operating System Research Build Tranmitter}}

CON
  _clkmode = xtal1 + pll16x                                               
  _xinfreq = 5_000_000
  
OBJ
  pst  : "Parallax Serial Terminal"
  PS2  : "PS2_Controller"
  xbee : "XBee_Object"
  
PUB Main
  pst.start(115200)
  pst.str(String("Beginning program for testing the PS2 controller...",13))

  PS2.start(12, 5000)
  repeat
    PS2_Interpret 

  
PUB PS2_Interpret
    waitcnt(clkfreq/2000 + cnt)                                                 'the higher the number, the faster the process is evaluated
    {Buttons}
    if (PS2.get_Data1 == $FFF75A73)
      pst.str(String("Pressed: START",13))
      xbee.start(4,3,0,9600)
    if (PS2.get_Data1 == $FFFE5A73)
      pst.str(String("Pressed: SELECT",13))
      xbee.stop

    {Right Control Stick}
    if (PS2.get_RightY <> 0) &(PS2.get_RightY <> 255) & (PS2.get_RightX <> 0) & (PS2.get_RightX <> 255)
      xbee.tx(1)
      pst.str(String("Sent: 1",13))

    CASE PS2.get_RightY
      0: xbee.tx(3)
        pst.str(String("Sent: 3",13))
      255: xbee.tx(2)
       pst.str(String("Sent: 2",13))

    CASE PS2.get_RightX
      0: xbee.tx(5)
        pst.str(String("Sent: 5",13))
      255: xbee.tx(4)
        pst.str(String("Sent: 4",13))
        